Filtering
Most v2 APIs for listing resources accept a filter string. A filter can be built of sub filters joined by the logical AND and OR operators, each sub filter is a field or precedence group followed by an operator followed by a value. A sub filter may have a prefix of the logical NOT operator. One or more sub filters can be grouped with the precedence operators. The sub filters in a precedence grouping are evaluated to a result before evaluating the rest of the filter. Precedence groups can be nested.
Use single quotes ('
) to surround strings. Dates used in filters are accepted in RFC3339 format such as "2006-01-02T15:04:05Z07:00"
, "2006-01-02T15:04:05"
or "2006-01-02"
.
A filter is provided as a query parameter like: api.infosum.com/api/v2/foo_bar?filter=name co 'foo' or name co 'bar'
. Filter strings can be constructed using the operations here:
Operator | Meaning | Example |
---|---|---|
eq | Is Equal To | name eq 'foo' |
ne | Not Equal To | name ne 'foo' |
co | Contains | name co 'Bar' |
ico | Contains (Case-Insensitive) | name ne 'bar' |
nc | Does Not Contain | name nc 'Bar' |
inc | Does Not Contain (Case-Insensitive) | name inc 'bar' |
lt | Less Than | score lt 10 |
le | Less Than Or Equal To | score le 10 |
gt | Greater Than | score gt 10 |
ge | Greater Than Or Equal To | score ge 10 |
and | Logical AND | score eq 10 and name eq 'foo' |
or | Logical OR | score eq 10 or score eq 10 |
not | Logical NOT | not score eq 10 |
( ) | Precedence | (score lt 100 and score gt 10) or name eq 'foo' |